package io.yuncheng.modules.sys.entity;

import com.alibaba.fastjson.JSON;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.yuncheng.common.utils.Constant;
import lombok.Data;

import java.util.Date;

/**
 *
 *  智能体告警日志接口
 * @Author shouxu
 * @Date 2020/11/25 15:25
 */
@Data
public class AgentWarningLogEntity {
    /**
     * appId
     */
    String appId;
    /**
     * 业务单号
     */
    String transactionId;
    /**
     * 告警类型
     */
    String alarmtype;
    /**
     * 算法
     */
    String algorithm;
    /**
     * 告警描述
     */
    String alarmtypeMsg;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    Date logDate;

    public SubAppWarnLogEntity buildByLog(){
        SubAppWarnLogEntity subAppWarnLogEntity = new SubAppWarnLogEntity();
        subAppWarnLogEntity.setAppUniqueId(getAppId());
        subAppWarnLogEntity.setAppStatus(Constant.StatusType.NORMAL.getValue() + "");
        subAppWarnLogEntity.setLogDate(getLogDate());
        subAppWarnLogEntity.setLogMessage(getAlarmtypeMsg());
        subAppWarnLogEntity.setTransactionId(getTransactionId());
        subAppWarnLogEntity.setCreateDate(new Date());
        return  subAppWarnLogEntity;
    }



    public static void main(String[] args) {
        AgentWarningLogEntity agentWarningLogEntity = new AgentWarningLogEntity();
        agentWarningLogEntity.setAppId("appid");
        agentWarningLogEntity.setTransactionId("42ba5ccc-9074-405a-bdcb-86a8da76e5eb");
        agentWarningLogEntity.setAlarmtype("earlywaring");
        agentWarningLogEntity.setAlarmtypeMsg("SM2算法调用趋势减少");
        agentWarningLogEntity.setAlgorithm("SM2");
        System.out.println(JSON.toJSONString(agentWarningLogEntity));
    }
}
